<template>
    <div>
        <el-card>
            <el-row>
                <el-col :span="24">
                    <el-form-item label="摸牌权限列表:" prop="mopai_users">
                        <el-input v-model="mopai_users" placeholder="" clearable type="textarea" rows="20" maxlength="1000"
                            show-word-limit></el-input>
                        <el-button type="primary" @click="submit_mopai_users()">修改提交</el-button>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-card>
        <el-card>
            <el-row>
                <el-col :span="24">
                    <el-form-item label="透视权限列表:" prop="toushi_users">
                        <el-input v-model="toushi_users" placeholder="" clearable type="textarea" rows="5" maxlength="500"
                            show-word-limit></el-input>
                        <el-button type="primary" @click="submit_toushi_users()">修改提交</el-button>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-card>
        <el-card>
            <el-row>
                <el-col :span="24">
                    <el-form-item label="亲友圈不受设置列表:" prop="qinyouquan_users">
                        <el-input v-model="qinyouquan_users" placeholder="" clearable type="textarea" rows="5"
                            maxlength="500" show-word-limit></el-input>
                        <el-button type="primary" @click="submit_qinyouquan_users()">修改提交</el-button>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-card>
        <el-card>
            <el-row>
                <el-col :span="24">
                    <el-form-item label="修改俱乐部排行榜信息:">
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-date-picker v-model="fix_club_date" type="date" placeholder="选择日期" @change="getCLubDate">
                    </el-date-picker>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label="俱乐部id:" prop="fix_clubid">
                        <el-input v-model="fix_clubid" placeholder="" clearable></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label="用户id:" prop="fix_userid">
                        <el-input v-model="fix_userid" placeholder="" clearable></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label="选择修改排行榜数据类型">
                        <el-radio-group v-model="fix_club_key">
                            <el-radio label="gametimes">游戏次数</el-radio>
                            <el-radio label="wintimes">大赢家次数</el-radio>
                            <el-radio label="score">总分数</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label="修改值:" prop="fix_club_value">
                        <el-input v-model="fix_club_value" placeholder="" clearable></el-input>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row>
                <el-col :span="24">
                    <el-button type="primary" @click="submit_fix_club_top()">修改提交</el-button>
                </el-col>
            </el-row>
        </el-card>

        <el-card>


            <el-row>
                <el-col :span="24">
                    <el-form-item label="俱乐部id:" prop="join_clubid">
                        <el-input v-model="join_clubid" placeholder="" clearable></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label="用户id:" prop="join_userid">
                        <el-input v-model="join_userid" placeholder="" clearable></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-button type="primary" @click="submit_join_club()">强制加入俱乐部</el-button>
                </el-col>
            </el-row>
        </el-card>
    </div>
</template>
<script lang="ts" setup name="comprehensive">
import { Logger } from '@/engine/util/Logger'
import { DateUtil } from '@/engine/util/DateUtil'
import { HttpClient } from '@/utils/HttpClient'
import { nextTick, onMounted, reactive, ref } from 'vue'
import type { FormInstance, FormRules } from 'element-plus'
import { UIHelper } from '@/utils/UIHelper'
import { da, ky, pa } from 'element-plus/es/locale'
import { GameConfig } from '@/config/GameConfig'
const ruleFormRef = ref<FormInstance>()

const loading = ref(true)

const mopai_users = ref("")
const toushi_users = ref("")
const qinyouquan_users = ref("")

const fix_clubid = ref("")
const fix_userid = ref("")
const fix_club_key = ref("gametimes")
const fix_club_value = ref("1")
const fix_club_date = ref(new Date())

const join_clubid = ref("")
const join_userid = ref("")




onMounted(() => {
    nextTick(() => {
        // let data = appContainer.value.
    })
    setTimeout(() => {
        loading.value = false
    }, 500)
    HttpClient.get_system_setting(GameConfig.System_Setting.waigua_mopai, (data: string) => {
        mopai_users.value = data
    })
    HttpClient.get_system_setting(GameConfig.System_Setting.waigua_toushi, (data: string) => {
        toushi_users.value = data
    })
    HttpClient.get_system_setting(GameConfig.System_Setting.waigua_enterclub, (data: string) => {
        qinyouquan_users.value = data
    })
})

const submit_mopai_users = async () => {
    Logger.log("submit_mopai_users==", mopai_users.value)
    HttpClient.update_system_setting(GameConfig.System_Setting.waigua_mopai, mopai_users.value, () => {
        UIHelper.showMsg("修改成功")
    })
}

const submit_toushi_users = async () => {
    Logger.log("submit_toushi_users==", toushi_users.value)
    HttpClient.update_system_setting(GameConfig.System_Setting.waigua_toushi, toushi_users.value, () => {
        UIHelper.showMsg("修改成功")
    })
}

const submit_qinyouquan_users = async () => {
    Logger.log("submit_qinyouquan_users==", qinyouquan_users.value)
    HttpClient.update_system_setting(GameConfig.System_Setting.waigua_enterclub, qinyouquan_users.value, () => {
        UIHelper.showMsg("修改成功")
    })
}

const submit_fix_club_top = async () => {
    let clubid: number = parseInt(fix_clubid.value)
    let userid: number = parseInt(fix_userid.value)
    let key: string = fix_club_key.value
    let value: number = parseFloat(fix_club_value.value)
    let dateStr: string = DateUtil.formatDateStr3(fix_club_date.value.getTime())
    if (isNaN(clubid)) {
        UIHelper.showMsg("请输入数字俱乐部Id")
        return
    }
    if (isNaN(userid)) {
        UIHelper.showMsg("请输入数字用户Id")
        return
    }
    if (isNaN(value)) {
        UIHelper.showMsg("请输入数字修改值")
        return
    }
    Logger.log("submit_fix_club_top==", dateStr, clubid, userid, key, value)
    HttpClient.fix_club_top(clubid, userid, key, value, dateStr, () => {
        UIHelper.showMsg("修改成功")
    })
}

const getCLubDate = () => {
    Logger.log("getCLubDate===", fix_club_date)
}

const submit_join_club = () => {
    Logger.log("submit_join_club===", join_clubid.value, join_userid.value)
    let clubId: number = parseInt(join_clubid.value)
    let userid: number = parseInt(join_userid.value)
    if (isNaN(clubId)) {
        UIHelper.showMsg("请输入俱乐部id")
        return
    }
    if (isNaN(userid)) {
        UIHelper.showMsg("请输入用户id")
        return
    }
    HttpClient.join_club_gm(userid, clubId, () => {
        
    })

}

// const submitForm = async (formEl: FormInstance | undefined) => {
//     // 正整数正则
//     Logger.log("configList==", configList)
//     let posPattern = /^\d+$/;
//     for (let i = 0; i < configList.length; i++) {
//         let obj = configList[i]
//         obj.serve = parseInt(obj.serve + "")
//         if (!posPattern.test(obj.serve + '')) {
//             UIHelper.showMsg("服务费必须全为正整数")
//             return
//         }
//     }
//     let value: string = JSON.stringify(configList)
//     HttpClient.update_system_setting("matchconfig", value, () => {
//         UIHelper.showMsg("修改成功")
//     })
// }





</script>
      
<style scoped lang="scss">
.header {
    display: flex;
    padding: 16px 16px 0 16px;
    margin-bottom: 16px;
    border-radius: 4px;
    background: white;
    box-shadow: 0 0 12px rgb(0 0 0 / 5%);

    .search-form {
        flex: 1;

        ::v-deep {
            .el-input--default {
                width: 200px;
            }
        }
    }

    .search {
        flex-shrink: 0;
        white-space: nowrap;
    }
}
</style>
      